import tikTokConfig from '../../../../api/config/channel/tikTok-config'
import * as globalTypes from '../../../../mutation-types'

/**
 * 查看抖音接入号列表
 * @param data
 */
export const getDouyinConfigs = ({commit, state, rootState, dispatch}, data) => {
  return tikTokConfig.getDouyinConfigs(data)
    .then(response => {
      return response
    })
    .catch(() => {
      commit(globalTypes.SET_ERROR, 'message.default_tips')
    })
}
/**
 * 更新抖音对接
 * @param data
 */
export const updateDouyinConfig = ({commit, state, rootState, dispatch}, data) => {
  return tikTokConfig.updateDouyinConfig(data)
    .then(response => {
      return response
    })
    .catch(() => {
      commit(globalTypes.SET_ERROR, 'message.default_tips')
    })
}
/**
 * 删除抖音对接
 * @param data
 */
export const removeDouyinConfig = ({commit, state, rootState, dispatch}, data) => {
  return tikTokConfig.removeDouyinConfig(data)
    .then(response => {
      return response
    })
    .catch(() => {
      commit(globalTypes.SET_ERROR, 'message.default_tips')
    })
}
/**
 * 查询抖音接入号信息
 * @param data
 */
export const getDouyinConfigById = ({commit, state, rootState, dispatch}, data) => {
  return tikTokConfig.getDouyinConfigById(data)
    .then(response => {
      return response
    })
    .catch(() => {
      commit(globalTypes.SET_ERROR, 'message.default_tips')
    })
}

